package com.zzyl.nursing.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.zzyl.common.core.domain.R;
import com.zzyl.nursing.dto.DoTaskDto;
import com.zzyl.nursing.dto.NursingTaskDto;
import com.zzyl.nursing.dto.TaskCancelDto;
import com.zzyl.nursing.vo.NursingTaskVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.zzyl.common.annotation.Log;
import com.zzyl.common.core.controller.BaseController;
import com.zzyl.common.core.domain.AjaxResult;
import com.zzyl.common.enums.BusinessType;
import com.zzyl.nursing.domain.NursingTask;
import com.zzyl.nursing.service.INursingTaskService;
import com.zzyl.common.utils.poi.ExcelUtil;
import com.zzyl.common.core.page.TableDataInfo;

/**
 * 护理任务Controller
 *
 * @author ruoyi
 * @date 2025-06-13
 */
@RestController
@RequestMapping("/nursing/nursingTask")
@Api(tags = "护理任务相关接口")
public class NursingTaskController extends BaseController {
    @Autowired
    private INursingTaskService nursingTaskService;

    /**
     * 查询护理任务列表
     */
    @PreAuthorize("@ss.hasPermi('nursing:nursingTask:list')")
    @GetMapping("/list")
    @ApiOperation(value = "获取护理任务列表")
    public TableDataInfo<List<NursingTaskVo>> list(NursingTaskDto nursingTaskDto) {
        startPage();
        List<NursingTaskVo> list = nursingTaskService.selectNursingTaskList(nursingTaskDto);
        return getDataTable(list);
    }


    /**
     * 获取护理任务详细信息
     */
    @PreAuthorize("@ss.hasPermi('nursing:nursingTask:{id}')")
    @GetMapping("/{id}")
    @ApiOperation(value = "获取护理任务详细信息")
    public AjaxResult getNursingTaskDetail(@PathVariable Integer id) {
        return success(nursingTaskService.getNursingTaskDetail(id));
    }



    /**
     * 取消任务
     */
    @PreAuthorize("@ss.hasPermi('nursing:nursingTask:cancel')")
    @PutMapping("cancel")
    @ApiOperation(value = "获取护理任务详细信息")
    public AjaxResult cancelTask(@RequestBody  TaskCancelDto taskCancelDto) {
        nursingTaskService.cancelTask(taskCancelDto);
        return success();
    }



    /**
     * 任务执行
     */
    @PreAuthorize("@ss.hasPermi('nursing:nursingTask:do')")
    @PutMapping("do")
    @ApiOperation(value = "获取护理任务详细信息")
    public AjaxResult doTask(@RequestBody DoTaskDto doTaskDto) {
        nursingTaskService.doTask(doTaskDto);
        return success();
    }


    /**
     * 任务改期
     */
    @PreAuthorize("@ss.hasPermi('nursing:nursingTask:updateTime')")
    @PutMapping("updateTime")
    @ApiOperation(value = "获取护理任务详细信息")
    public AjaxResult updateTaskTime(@RequestBody DoTaskDto doTaskDto) {
        nursingTaskService.updateTaskTime(doTaskDto);
        return success();
    }


}
